﻿@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>研发项目节点维护</title>
    <link href="~/Scripts/jquery-easyui-1.5.4.4/themes/bootstrap/easyui.css" rel="stylesheet" />
    <script src="~/Scripts/jquery-easyui-1.5.4.4/jquery.min.js"></script>
    <script src="~/Scripts/jquery-easyui-1.5.4.4/jquery.easyui.min.js"></script>
    <script src="~/Scripts/jquery-easyui-1.5.4.4/plugins/jquery.filebox.js"></script>
    <script src="~/Scripts/jquery-easyui-1.5.4.4/locale/easyui-lang-zh_CN.js"></script>
    <link href="~/Content/themes/icon.css" rel="stylesheet" />
    <script src="~/Content/js/common.js"></script>
    <link href="~/Content/themes/table.css" rel="stylesheet" />
    <link href="~/Content/formstyles.css" rel="stylesheet" />
    <script type="text/javascript">
        $(function () {
            $.ajax({     //请求当前用户可以操作的按钮
                url: "/Button/GetUserAuthorizeButton?r=" + Math.random(),
                type: "post",
                data: { "KeyCode": "PMMaintain", "KeyName": "PMMaintain" },
                dataType: "json",
                timeout: 5000,
                success: function (data) {
                    if (data.success) {
                        var toolbar = getToolBar(data);      //common.js
                        if (data.search) {     //判断是否有浏览权限
                            var oldSelectRoleId;   //上次点选的RoleId
                            $("#ui_pm_dg").datagrid({       //初始化datagrid
                                url: "/Project/GetAllPMInfo",
                                striped: true, rownumbers: true, pagination: true, pageSize: 20, singleSelect: true,
                                idField: 'ProjectID',
                                sort: 'UpdateTime',
                                Order: 'asc',
                                pageList: [20, 40, 60, 80, 100],
                                frozenColumns: [[
                                               {
                                                   hidden: true,
                                                   title: 'ID',
                                                   field: 'ProjectID'
                                               },
                                                 {
                                                     width: '100',
                                                     title: '项目编码',
                                                     field: 'ProjectNo',
                                                     formatter: function (value, row, index) {
                                                         return value.length > 8 ? '<span title="' + value + '">' + value + '</span>' : value;
                                                     }
                                                 },
                                                 {
                                                     width: '120',
                                                     title: '项目名称',
                                                     field: 'ProjectName',
                                                     formatter: function (value, row, index) {
                                                         return value.length > 8 ? '<span title="' + value + '">' + value + '</span>' : value;
                                                     }
                                                 }
                                ]],
                                columns: [[
                                  { field: 'ProjectClerk', title: '业务员', sortable: false, width: 80 },
                                { field: 'ProjectManager', title: '管理员', sortable: false, width: 80 },
                                 { field: 'UpdateBy', title: '最后更新人', width: 80 },
                                  { field: 'UpdateTime', title: '最后更新时间', sortable: true, width: 135 },
                                    { field: 'CreateBy', title: '创建人', width: 80 },
                                { field: 'CreateTime', title: '创建时间', sortable: true, width: 135 },
                                           {
                                               field: 'Remark', title: '项目说明', width: 200,
                                               formatter: function (value, row, index) {
                                                   return value.length > 20 ? '<span title="' + value + '">' + value + '</span>' : value;
                                               }
                                           }]],
                                toolbar: toolbar.length == 0 ? null : toolbar,
                                onSelect: function (rowIndex, rowData) {

                                }
                            });
                        }
                        else {
                            $.show_alert("提示", "无权限，请联系管理员！");
                        }
                    } else {
                        $.show_alert("错误", data.result);
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    if (textStatus == "timeout") {
                        $.show_alert("提示", "请求超时，请刷新当前页重试！");
                    }
                    else {
                        $.show_alert("错误", textStatus + "：" + errorThrown);
                    }
                }
            })

            //回车搜索
            $("#ui_pm_search").find('input').on('keyup', function (event) {
                if (event.keyCode == '13') {
                    ui_pm_searchdata();
                }
            })

        });
        //根据附件列表id上传附件,更新表格
        function uploadfile(appendlistid,appenddatagrid) {
            $("<div/>").dialog({
                id: "ui_pm_upload_dialog",
                href: "/Project/uploadform",
                title: "上传附件",
                height: 270,
                width: 510,
                modal: true,
                buttons: [{
                    id: "ui_file_add_btn",
                    text: '添 加',
                    handler: function () {
                        //获取上传文件控件内容
                        var file = $("#fileImport").filebox("files")[0];
                        //判断控件中是否存在文件内容，如果不存在，弹出提示信息，阻止进一步操作
                        if (file == null) { alert('错误，请选择文件'); return; }
                        //获取文件名称
                        var fileName = file.name;
                        //获取文件类型名称
                        var file_typename = fileName.substring(fileName.lastIndexOf('.'), fileName.length);
                        //这里限定上传文件文件类型必须为.xlsx，如果文件类型不符，提示错误信息
                        if (file_typename == '.xlsx' || true) {
                            //计算文件大小
                            var fileSize = 0;
                            //如果文件大小大于1024字节X1024字节，则显示文件大小单位为MB，否则为KB
                            if (file.size > 1024 * 1024) {
                                fileSize = Math.round(file.size * 100 / (1024 * 1024)) / 100;
                                if (fileSize > 10) {
                                    alert('错误，文件超过10MB，禁止上传！'); return;
                                }
                                fileSize = fileSize.toString() + 'MB';
                            }
                            else {
                                fileSize = (Math.round(file.size * 100 / 1024) / 100).toString() + 'KB';
                            }
                            //将文件名和文件大小显示在前端label文本中
                            document.getElementById('fileName').innerHTML = "<span style='color:Blue'>文件名: " + file.name + ',大小: ' + fileSize + "</span>";
                            //获取form数据
                            var formData = new FormData($("#importFileForm")[0]);
                            //调用apicontroller后台action方法，将form数据传递给后台处理。contentType必须设置为false,否则chrome和firefox不兼容
                            $.ajax({
                                url: "/Project/uploadfile?appendlistid=" + appendlistid + "&r=" + Math.random(),
                                type: 'POST',
                                data: formData,
                                async: false,
                                cache: false,
                                contentType: false,
                                processData: false,
                                success: function (returnInfo) {
                                    //上传成功后将控件内容清空，并显示上传成功信息
                                    document.getElementById('fileImport').value = null;
                                    document.getElementById('uploadInfo').innerHTML = "<span style='color:Red'>" + returnInfo + "</span>";
                                    appenddatagrid.datagrid("reload");//刷新附件清单
                                },
                                error: function (returnInfo) {
                                    //上传失败时显示上传失败信息
                                    document.getElementById('uploadInfo').innerHTML = "<span style='color:Red'>" + returnInfo + "</span>";
                                }
                            });
                        }
                        else {
                            alert("文件类型错误");
                            //将错误信息显示在前端label文本中
                            document.getElementById('fileName').innerHTML = "<span style='color:Red'>错误提示:上传文件应该是.xlsx后缀而不应该是" + file_typename + ",请重新选择文件</span>"
                        }
                    }
                }, {
                    text: '关 闭',
                    handler: function () {
                        $("#ui_pm_upload_dialog").dialog('destroy');
                     
                    }
                }],
                onLoad: function () {

                },
                onClose: function () {
                    $("#ui_pm_upload_dialog").dialog('destroy');  //销毁dialog对象                    
                }
            });
        }
        //根据附件id删除附件，更新表格
        function Delfile(appenddatagrid) {
            var rows = appenddatagrid.datagrid("getChecked");
            if (rows.length < 1) {
                $.show_alert("提示", "请先勾选要删除的项目");
                return;
            }
            if (rows.length > 1) {
                $.show_alert("提示", "不支持批量删除");
                appenddatagrid.datagrid('clearSelections').datagrid('clearChecked');
                return;
            }
            $.messager.confirm('提示', '确定删除：' + rows[0].AppendName + '？', function (r) {
                if (r) {
                    $.ajax({
                        url: "/Project/DelAppendByID?r=" + Math.random(),
                        data: {
                            ID: rows[0].AppendID,
                            AppendPath: rows[0].AppendPath
                        },
                        type: "POST",
                        dataType: "json",
                        success: function (data) {
                            if (data.success) {
                                $.show_alert("提示", data.msg);
                                $("#ui_pm_dg").datagrid("reload").datagrid('clearSelections').datagrid('clearChecked');
                                appenddatagrid.datagrid("reload");//刷新附件清单
                                ////如果“用户管理”标签页处于打开状态需要刷新，否则被删除的角色还显示，再点编辑用户就出错
                                //if ($('#tabs').tabs('exists', '用户管理')) {
                                //    $('#tabs').tabs('getTab', '用户管理').panel('refresh');
                                //}

                            } else {
                                $.show_alert("提示", data.msg);
                            }
                        }
                    });
                }
            });
        }
        function downloadfile(appenddatagrid) {
            var rows = appenddatagrid.datagrid("getChecked");
            if (rows.length < 1) {
                $.show_alert("提示", "请先勾选要下载的项目");
                return;
            }
            if (rows.length > 1) {
                $.show_alert("提示", "不支持批量处理");
                appenddatagrid.datagrid('clearSelections').datagrid('clearChecked');
                return;
            }
           // var path = "${ctx}/file/download.do?filePath=" + value ;  
            window.open("../uploads/" + rows[0].AppendPath);
        }
        //修改项目
        function EditPMMaintain() {
            var row = $("#ui_pm_dg").datagrid("getSelected");
            if (row.length < 1) {
                $.show_alert("提示", "请先勾选要更新的项目");
                return;
            }
            if (row.length > 1) {
                $.show_alert("提示", "不支持批量修改项目");
                $("#ui_pm_dg").datagrid('clearSelections').datagrid('clearChecked');
                return;
            }
            $("<div/>").dialog({
                id: "ui_pm_edit_dialog",
                href: "/Project/PMEdit",
                title: "更新项目",
                height: $(window).height(),
                width: $(window).width(),
                modal: true,
                toolbar: [{
                    text: '保存',
                    iconCls: 'icon-save',
                    handler: function () {
                        $.ajax({     //提交数据保存
                            url: "/Project/EditPM?r=" + Math.random(),
                            type: "post",
                            data: {                                
                                "ProjectID": $("#ProjectID").val(),
                                "bsPSTime": $("#bsPSTime").datebox('getValue'),
                                "bsPETime": $("#bsPETime").datebox('getValue'),
                                "bsRSTime": $("#bsRSTime").datebox('getValue'),
                                "bsRETime": $("#bsRETime").datebox('getValue'),
                                "bsRemark": $("#bsRemark").val(),
                                "bsExecutor": $("#bsExecutor").val(),

                                "tyPSTime": $("#tyPSTime").datebox('getValue'),
                                "tyPETime": $("#tyPETime").datebox('getValue'),
                                "tyRSTime": $("#tyRSTime").datebox('getValue'),
                                "tyRETime": $("#tyRETime").datebox('getValue'),
                                "tyRemark": $("#tyRemark").val(),
                                "tyExecutor": $("#tyExecutor").val(),

                                "dnPSTime": $("#dnPSTime").datebox('getValue'),
                                "dnPETime": $("#dnPETime").datebox('getValue'),
                                "dnRSTime": $("#dnRSTime").datebox('getValue'),
                                "dnRETime": $("#dnRETime").datebox('getValue'),
                                "dnRemark": $("#dnRemark").val(),
                                "dnExecutor": $("#dnExecutor").val(),

                                "mePSTime": $("#mePSTime").datebox('getValue'),
                                "mePETime": $("#mePETime").datebox('getValue'),
                                "meRSTime": $("#meRSTime").datebox('getValue'),
                                "meRETime": $("#meRETime").datebox('getValue'),
                                "meRemark": $("#meRemark").val(),
                                "meExecutor": $("#meExecutor").val(),
                                "estworktime": $("#estWorkTime").val(),//预估工时
                                "weight1": $("#weight1").val(),//重量1
                                "weight2": $("#weight2").val(),//重量2
                                "workitem1": $("#workitem1").combogrid("getText"),//工时项目类别1
                                "workitem2": $("#workitem2").combogrid("getText"),// 

                                "cnPSTime": $("#cnPSTime").datebox('getValue'),
                                "cnPETime": $("#cnPETime").datebox('getValue'),
                                "cnRSTime": $("#cnRSTime").datebox('getValue'),
                                "cnRETime": $("#cnRETime").datebox('getValue'),
                                "cnRemark": $("#cnRemark").val(),
                                 "cnExecutor": $("#cnExecutor").val()
                            },
                            dataType: "json",
                            timeout: 5000,
                            success: function (data) {
                                if (data.success) {
                                    $.show_alert("成功", "保存成功！");
                                    //$("#ui_pm_edit_dialog").dialog('destroy');保存后不自动关闭
                                   // $("#ui_pm_dg").datagrid("reload");//.datagrid('clearSelections').datagrid('clearChecked');
                                } else {
                                    $.show_alert("提示", data.msg);
                                }
                            },
                            error: function (XMLHttpRequest, textStatus, errorThrown) {
                                if (textStatus == "timeout") {
                                    $.show_alert("提示", "请求超时，请刷新当前页重试！");
                                }
                                else {
                                    $.show_alert("错误", textStatus + "：" + errorThrown);
                                }
                            }
                        })
                    }
                },
                {
                    text: '关闭',
                    iconCls: 'icon-cross',
                    handler: function () {
                        $("#ui_pm_edit_dialog").dialog('destroy');
                        //$("#ui_pm_dg").datagrid("reload");
                    }
                }],
                //修改窗口加载后
                onLoad: function () {
                    bangdingnodedata(row);
        },
                //编辑窗口关闭
                onClose: function () {
                    $("#ui_pm_edit_dialog").dialog('destroy');  //销毁dialog对象 
                        $("#ui_pm_dg").datagrid("reload");//主表更新！
                }
            });

        }
        //查看项目
        function SeebillPMMaintain() {
                var row = $("#ui_pm_dg").datagrid("getSelected");
                if (row.length < 1) {
                    $.show_alert("提示", "请先勾选要查看的项目");
                    return;
                }
                if (row.length > 1) {
                    $.show_alert("提示", "不支持批量查看项目");
                    $("#ui_pm_dg").datagrid('clearSelections').datagrid('clearChecked');
                    return;
                }
                $("<div/>").dialog({
                    id: "ui_pm_view_dialog",
                    href: "/Project/PMEdit",
                    title: "查看项目",
                    height: $(window).height(),
                    width: $(window).width(),
                    modal: true,
                    toolbar: [
                    {    text: '关闭',
                        iconCls: 'icon-cross',
                        handler: function () { $("#ui_pm_view_dialog").dialog('destroy'); }
                    }],
                    //修改窗口加载后
                    onLoad: function() {                    
                        bangdingnodedata(row); 
                    },
                    onOpen: function () {
                        setTimeout(function () {
                            $(".easyui-textbox").textbox('readonly', true);//设置所有输入项为readonly
                            $(".easyui-datebox").textbox('readonly', true);//设置所有日期输入项为readonly
                            $(".icon-delete").parent().parent().linkbutton("disable");//禁止附件管理的删除、添加
                            $(".icon-add").parent().parent().linkbutton("disable");
                        }, 1000);
                       
                    },
                    //编辑窗口关闭
                    onClose: function () {
                        $("#ui_pm_view_dialog").dialog('destroy');  //销毁dialog对象                       
                    }
                });
        }

        function bangdingnodedata(row){
        
            //绑定项目基本信息
            $("#ProjectID").val(row.ProjectID);
            $("#ProjectNo").textbox('setValue', row.ProjectNo);
            $("#ProjectName").textbox('setValue', row.ProjectName);
            $("#ProjectManager").textbox('setValue', row.ProjectManager);
            $("#ProjectClerk").textbox('setValue', row.ProjectClerk);
            $("#CreateBy").textbox('setValue', row.CreateBy);
            $("#CreateTime").textbox('setValue', row.CreateTime);
            $("#UpdateTime").textbox('setValue', row.UpdateTime);
            $("#UpdateBy").textbox('setValue', row.UpdateBy);
            $("#Remark").textbox('setValue', row.Remark);

            //加载当前项目的各节点时间进度信息
            $.ajax({
                url: "/Project/GetPMNodeInfo?r=" + Math.random(),
                type: "post",
                data: { "ProjectID": row.ProjectID, "KeyName": "PMMaintain" },
                dataType: "json",
                timeout: 5000,
                success: function (data) {
                    if (data.success == true) {
                        //单据加载节点信息
                        for (var i = 0; i < data.rows.length; i++) {
                            //项目商务bs
                            if (data.rows[i].NodeID == "2") {
                                $("#bsExecutor").textbox('setValue', data.rows[i].executor);
                                $("#bsPSTime").datebox('setValue', data.rows[i].PSTime.replace(/\//g, '-'));//将全局的\号替换为-，使得js能识别为日期格式
                                $("#bsPETime").datebox('setValue', data.rows[i].PETime.replace(/\//g, '-'));
                                $("#bsRSTime").datebox('setValue', data.rows[i].RSTime.replace(/\//g, '-'));
                                $("#bsRETime").datebox('setValue', data.rows[i].RETime.replace(/\//g, '-'));
                                $("#bsRemark").textbox('setValue', data.rows[i].Remark);
                                //加载附件,data.rows[i].AppendListID
                                var aid = data.rows[i].AppendListID;
                                $('#bsdatagrid').datagrid({
                                    url: "/Project/GetAppendList?AppendListID=" + aid + "&r=" + Math.random(),
                                    toolbar: [{
                                        text: '添加',
                                        iconCls: 'icon-add',
                                        handler: function () {
                                            uploadfile(aid, $("#bsdatagrid"));
                                        }
                                    }, {
                                        text: '删除',
                                        iconCls: 'icon-delete',
                                        handler: function () {
                                            Delfile($("#bsdatagrid"));
                                        }
                                    }, {
                                        text: '下载附件',
                                        iconCls: 'icon-save',
                                        handler: function () {
                                            downloadfile($("#bsdatagrid"));
                                        }
                                    }]
                                });
                            }
                                //合同签订ty
                            else if (data.rows[i].NodeID == "3") {

                                $("#tyExecutor").textbox('setValue', data.rows[i].executor);
                                $("#tyPSTime").datebox('setValue', data.rows[i].PSTime.replace(/\//g, '-'));
                                $("#tyPETime").datebox('setValue', data.rows[i].PETime.replace(/\//g, '-'));
                                $("#tyRSTime").datebox('setValue', data.rows[i].RSTime.replace(/\//g, '-'));
                                $("#tyRETime").datebox('setValue', data.rows[i].RETime.replace(/\//g, '-'));
                                $("#tyRemark").textbox('setValue', data.rows[i].Remark);
                                var aid3 = data.rows[i].AppendListID;
                                $('#tydatagrid').datagrid({
                                    url: "/Project/GetAppendList?AppendListID=" + aid3 + "&r=" + Math.random(),
                                    toolbar: [{
                                        text: '添加',
                                        iconCls: 'icon-add',
                                        handler: function () {
                                            uploadfile(aid3, $("#tydatagrid"));
                                        }
                                    }, {
                                        text: '删除',
                                        iconCls: 'icon-delete',
                                        handler: function () {
                                            Delfile($("#tydatagrid"));
                                        }
                                    }, {
                                        text: '下载附件',
                                        iconCls: 'icon-save',
                                        handler: function () {
                                            downloadfile($("#tydatagrid"));
                                        }
                                    }]
                                });
                            }
                                //设计时间dn
                            else if (data.rows[i].NodeID == "4") {
                                $("#dnExecutor").textbox('setValue', data.rows[i].executor);
                                $("#dnPSTime").datebox('setValue', data.rows[i].PSTime.replace(/\//g, '-'));
                                $("#dnPETime").datebox('setValue', data.rows[i].PETime.replace(/\//g, '-'));
                                $("#dnRSTime").datebox('setValue', data.rows[i].RSTime.replace(/\//g, '-'));
                                $("#dnRETime").datebox('setValue', data.rows[i].RETime.replace(/\//g, '-'));
                                $("#dnRemark").textbox('setValue', data.rows[i].Remark);
                                var aid4 = data.rows[i].AppendListID;
                                $('#dndatagrid').datagrid({
                                    url: "/Project/GetAppendList?AppendListID=" + aid4 + "&r=" + Math.random(),
                                    toolbar: [{
                                        text: '添加',
                                        iconCls: 'icon-add',
                                        handler: function () {
                                            uploadfile(aid4, $("#dndatagrid"));
                                        }
                                    }, {
                                        text: '删除',
                                        iconCls: 'icon-delete',
                                        handler: function () {
                                            Delfile($("#dndatagrid"));
                                        }
                                    }, {
                                        text: '下载附件',
                                        iconCls: 'icon-save',
                                        handler: function () {
                                            downloadfile($("#dndatagrid"));
                                        }
                                    }]
                                });
                            }
                                //生产制造me,带预估工时
                            else if (data.rows[i].NodeID == "5") {
                                $("#meExecutor").textbox('setValue', data.rows[i].executor);
                                $("#mePSTime").datebox('setValue', data.rows[i].PSTime.replace(/\//g, '-'));
                                $("#mePETime").datebox('setValue', data.rows[i].PETime.replace(/\//g, '-'));
                                $("#meRSTime").datebox('setValue', data.rows[i].RSTime.replace(/\//g, '-'));
                                $("#meRETime").datebox('setValue', data.rows[i].RETime.replace(/\//g, '-'));
                                $("#meRemark").textbox('setValue', data.rows[i].Remark);
                                $("#estWorkTime").textbox('setValue', data.rows[i].EstWorkTime);
                                $("#weight1").textbox('setValue', data.rows[i].weight1);
                                $("#weight2").textbox('setValue', data.rows[i].weight2);
                                $("#workitem1").val(data.rows[i].workitem1);//input 赋值
                                $("#workitem2").val(data.rows[i].workitem2);
                                //为工时类绑定下拉选择内容；
                                $("input[id^='workitem']").combogrid({//以workitem开头的id 
                                    delay: 500,
                                    mode: 'remote',
                                    panelWidth: 200,
                                    //value: '请选择类别',
                                    idField: 'itemNo',
                                    textField: 'itemClass',
                                    url: "/Project/GetWorkTimeClass?&r=", //+ Math.random(),//获取工时项目类json数据
                                    columns: [[
                                    //{ field: 'itemNo', title: 'ID', width: 20 },
                                    { field: 'itemClass', title: '类别', width: 150 },
                                    { field: 'Stime', title: '工时', width: 30 }
                                    ]]
                                });
                                //为工时绑定自动计算功能
                                $("#estWorkTime").textbox({
                                    buttonText: "计算工时",
                                    buttonAlign:"right",
                                    onClickButton: function () { 
									var stime1=0,stime2=0;
									var g1 = $('#workitem1').combogrid('grid');
									var g2 = $('#workitem2').combogrid('grid');
									if(g1.datagrid('getSelected')==null)//未选择
									{
										//判断是否符合选项
										var text1=$("#workitem1").combogrid("getText");
										var rows=g1.datagrid('getRows');
										for(var i=0;i<rows.length;i++){
											if(text1==rows[i].itemClass){stime1=rows[i].Stime;break;}
										}
									}else
									{
										stime1=g1.datagrid('getSelected').Stime;
									}
									if(g2.datagrid('getSelected')==null)//未选择
									{
										var text2=$("#workitem2").combogrid("getText");
										var rows=g1.datagrid('getRows');
										for(var i=0;i<rows.length;i++){
											if(text2==rows[i].itemClass){stime2=rows[i].Stime;break;}
										}
									}else
									{
										stime2=g2.datagrid('getSelected').Stime;
									}									
                                        try {                                           
                                            var w1=$("#weight1").val();
                                            var w2 = $("#weight2").val();
                                            var time=stime1*w1+stime2*w2;                                            
                                            $("#estWorkTime").textbox('setValue', time);
                                        } catch (e) {
                                            $.show_alert("提示", "工时项目类别输入格式有误,请重新输入！");
                                        }
                                        
                                    }

                                });
                             

                                var aid5 = data.rows[i].AppendListID;
                                $('#medatagrid').datagrid({
                                    url: "/Project/GetAppendList?AppendListID=" + aid5 + "&r=" + Math.random(),
                                    toolbar: [{
                                        text: '添加',
                                        iconCls: 'icon-add',
                                        handler: function () {
                                            uploadfile(aid5, $("#medatagrid"));
                                        }
                                    }, {
                                        text: '删除',
                                        iconCls: 'icon-delete',
                                        handler: function () {
                                            Delfile($("#medatagrid"));
                                        }
                                    }, {
                                        text: '下载附件',
                                        iconCls: 'icon-save',
                                        handler: function () {
                                            downloadfile($("#medatagrid"));
                                        }
                                    }]
                                });

                            }
                                //施工管理cn
                            else if (data.rows[i].NodeID == "6") {
                                $("#cnExecutor").textbox('setValue', data.rows[i].executor);
                                $("#cnPSTime").datebox('setValue', data.rows[i].PSTime.replace(/\//g, '-'));
                                $("#cnPETime").datebox('setValue', data.rows[i].PETime.replace(/\//g, '-'));
                                $("#cnRSTime").datebox('setValue', data.rows[i].RSTime.replace(/\//g, '-'));
                                $("#cnRETime").datebox('setValue', data.rows[i].RETime.replace(/\//g, '-'));
                                $("#cnRemark").textbox('setValue', data.rows[i].Remark);
                                var aid6 = data.rows[i].AppendListID;
                                $('#cndatagrid').datagrid({
                                    url: "/Project/GetAppendList?AppendListID=" + data.rows[i].AppendListID + "&r=" + Math.random(),
                                    toolbar: [{
                                        text: '添加',
                                        iconCls: 'icon-add',
                                        handler: function () {
                                            uploadfile(aid6, $("#cndatagrid"));
                                        }
                                    }, {
                                        text: '删除',
                                        iconCls: 'icon-delete',
                                        handler: function () {
                                            Delfile($("#cndatagrid"));
                                        }
                                    }, {
                                        text: '下载附件',
                                        iconCls: 'icon-save',
                                        handler: function () {
                                            downloadfile($("#cndatagrid"));
                                        }
                                    }]
                                });
                            }
                        }

                    } else {
                        $.show_alert("错误", data.msg);
                    }
                }
                ,
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    if (textStatus == "timeout") {
                        $.show_alert("提示", "请求超时，请刷新当前页重试！");
                    }
                    else {
                        $.show_alert("错误", textStatus + "：" + errorThrown);
                    }
                }
            }); 
                                
        }

      



        function ui_pm_searchdata() {
            $("#ui_pm_dg").datagrid('load', {
                ProjectNo: $('#txtProjectNo').val(),
                ProjectName: $('#txtPMName').val(),
                status: $('#FStatus').val(),
                CreateTimeS: $('#txtAddBeginDate').datetimebox('getValue'),
                CreateTimeE: $('#txtAddEndDate').datetimebox('getValue')
            });
            // $("#ui_pm_dg").datagrid('clearSelections').datagrid('clearChecked');
        }

        function ui_pm_cleardata() {
            $('#ui_pm_search input').val('');
            $('#ui_pm_search select').val('select');
            $('#txtAddBeginDate').datetimebox('setValue', '');
            $('#txtAddEndDate').datetimebox('setValue', '');
            $("#ui_pm_dg").datagrid('load', {});//清空条件自动加载数据

            //  $("#ui_pm_dg").datagrid('clearSelections').datagrid('clearChecked');
        }
    </script>
</head>
<body>
    <div id="ui_pm_layout" class="easyui-layout" data-options="fit:true,border:false">
        <div data-options="region:'north',split:true,border:true,collapsed:true" title="条件搜索" style="height:104px;">
            <div id="ui_pm_search">
                <table class="tableForm" style="width: 99%; height: 100%; background: #F5F5F5;">
                    <tr>
                        <th>
                            项目编码：
                        </th>
                        <td>
                            <input name="txtProjectNo" id="txtProjectNo" class="easyui-validatebox textbox" style="width:150px;height:22px;" />
                        </td>

                        <th>
                            项目名称：
                        </th>
                        <td>
                            <input name="txtPMName" id="txtPMName" class="easyui-validatebox textbox" style="width:150px;height:22px;" />
                        </td>

                        <th>
                            项目状态：
                        </th>
                        <td>
                            <select name="FStatus" id="FStatus">
                                <option value="select">请选择</option>
                                <option value="0">未确认</option>
                                <option value="1">已确认</option>
                                <option value="2">已完成</option>
                            </select>
                        </td>

                    <tr>
                        <th>
                            添加时间：
                        </th>
                        <td>
                            <input name="txtAddBeginDate" id="txtAddBeginDate" class="easyui-datetimebox"
                                   editable="false" style="width:150px;height:22px;" />
                        </td>

                        <th>
                            至：
                        </th>
                        <td>
                            <input name="txtAddEndDate" id="txtAddEndDate" class="easyui-datetimebox"
                                   editable="false" style="width:150px;height:22px;" />
                        </td>
                        <td colspan="4">
                            <a href="javascript:void(0);" class="easyui-linkbutton" iconcls="icon-search" plain="true"
                               onclick="ui_pm_searchdata();">搜索</a>
                            <a href="javascript:void(0);" class="easyui-linkbutton" iconcls="icon-clear" plain="true"
                               onclick="ui_pm_cleardata();">清空条件</a>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
        <div data-options="region:'center',border:false">
            <table id="ui_pm_dg" data-options="fit:true,border:false"></table>
        </div>
    </div>  
</body>
</html>
